/*/////////////////////////////////////////////////////////////////////////////////
/// An
///    ___   ____ ___ _____ ___  ____
///   / _ \ / ___|_ _|_   _/ _ \|  _ \
///  | | | | |  _ | |  | || | | | |_) |
///  | |_| | |_| || |  | || |_| |  _ <
///   \___/ \____|___| |_| \___/|_| \_\
///                              File
///
/// Copyright (c) 2008-2009 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU Lesser General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place - Suite 330, Boston, MA 02111-1307, USA, or go to
//http://www.gnu.org/copyleft/lesser.txt.
////////////////////////////////////////////////////////////////////////////////*/

#pragma once

namespace Ogitors
{

class OgitorExport CMultiSelEditor : public CBaseEditor
{
    friend class CMultiSelEditorFactory;
public:
    static OgitorsPropertyDefMap propertyDefs;
    
    /// Returns the Factory associated with this object
	static CBaseEditorFactory    *getFactory();
    /// Returns the Factory associated with this object can be overridden
	virtual CBaseEditorFactory   *getFactoryDynamic();

    virtual void    attach(CBaseEditor *parent);
	virtual void    detach();
	virtual void    showBoundingBox(bool bShow);
    void            deleteObjects();
    
    virtual void    getObjectProperties(Ogre::NameValuePairList &retList);
    NameObjectPairList getSelection() {return m_SelectedObjects;};   
	/// Overridden by Editor Objects to Backup Object Properties
    virtual OGITORUNDOSTRUCT getUndoData(OGITORUNDOTYPE undotype);

    /// Overridden by Editor Objects to Restore Object Properties
    virtual void     restore(Ogre::NameValuePairList &retList);

    void             setPosition(const Ogre::Vector3& position, bool display) {setDerivedPosition(position);};
    Ogre::Vector3    getPosition() {return m_Node->getPosition();};
    void             setOrientation(const Ogre::Quaternion& orientation, bool display) {setDerivedOrientation(orientation);};
    Ogre::Quaternion getOrientation() {return m_Node->getOrientation();};
    void             setScale(const Ogre::Vector3& val, bool display);
    Ogre::Vector3    getScale() {return m_Node->getScale();};

    virtual Ogre::AxisAlignedBox  getAABB() {return m_AABB;};
    virtual Ogre::SceneNode      *getNode() {return m_Node;};
	virtual Ogre::Vector3	      getDerivedPosition() {return m_Node->_getDerivedPosition();};
	virtual Ogre::Quaternion      getDerivedOrientation() {return m_Node->_getDerivedOrientation();};
    virtual Ogre::Vector3         getDerivedScale() {return m_Node->_getDerivedScale();};

    void            setSelection(NameObjectPairList &newselection);

	virtual void    setDerivedPosition(Ogre::Vector3 val);
    virtual void    setDerivedOrientation(Ogre::Quaternion val);

protected:
	NameObjectPairList   m_SelectedObjects;
    NameObjectPairList   m_ModifyList;
    Ogre::AxisAlignedBox m_AABB;
    Ogre::SceneNode *m_Node;
    
    CMultiSelEditor(const Ogre::String& name);
	virtual     ~CMultiSelEditor();

    void         _createModifyList();
};

class OgitorExport CMultiSelEditorFactory: public CBaseEditorFactory
{
public:
  CMultiSelEditorFactory();
  virtual ~CMultiSelEditorFactory() {};
  virtual void Init();
  virtual CBaseEditor *CreateObject(CBaseEditor **parent, Ogre::NameValuePairList &params);
};
}
